package MapReduce.Demo12_BookJoin.reduceJoin;

import MapReduce.writableBean.BookBorrowWritable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * @Author:lixinlei
 * @Date:2022/3/24 9:15
 **/
public class BookReduceJoinSecondGroupComparator extends WritableComparator {

    public BookReduceJoinSecondGroupComparator(){
        super(BookBorrowWritable.class,true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        BookBorrowWritable aBean = (BookBorrowWritable)a;
        BookBorrowWritable bBean = (BookBorrowWritable)b;

        String aPersonId = aBean.getPersonId();
        String bPersonId = bBean.getPersonId();

        return aPersonId.compareTo(bPersonId);
    }
}
